<template>
  <div class="app-container">
    <!-- 高级查询 -->
    <el-form v-show="searchVisible" ref="queryForm" :model="queryParams" :inline="true">
      <el-form-item label="发票号:">
        <el-input v-model="queryParams.invoiceNo" size="small" placeholder="请输入发票号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="支付流水号:">
        <el-input v-model="queryParams.slipNo" size="small" placeholder="请输入支付流水号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.storeName" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label=":">
        <el-input v-model="queryParams.mallName" size="small" placeholder="请输入" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="所属域:">
        <el-input v-model="queryParams.site" size="small" placeholder="请输入所属域" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="付款收款人(这里指供应商):">
        <el-input v-model="queryParams.payCust" size="small" placeholder="请输入付款收款人(这里指供应商)" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="付款人:">
        <el-input v-model="queryParams.billToCust" size="small" placeholder="请输入付款人" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="是否合作伙伴:">
        <el-input v-model="queryParams.ptnrYn" size="small" placeholder="请输入是否合作伙伴" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="凭证日期:">
        <el-date-picker v-model="queryParams.slipDt" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择凭证日期" clearable />
      </el-form-item>
      <el-form-item label="结算货币金额:">
        <el-input v-model="queryParams.amtCur" size="small" placeholder="请输入结算货币金额" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="汇总年月:">
        <el-input v-model="queryParams.jobMonth" size="small" placeholder="请输入汇总年月" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="汇率:">
        <el-input v-model="queryParams.exrate" size="small" placeholder="请输入汇率" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="结算货币:">
        <el-input v-model="queryParams.curr" size="small" placeholder="请输入结算货币" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="SKU单价:">
        <el-input v-model="queryParams.rate" size="small" placeholder="请输入SKU单价" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="汇总结算数量:">
        <el-input v-model="queryParams.wtCnt" size="small" placeholder="请输入汇总结算数量" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="结算科目编码:">
        <el-input v-model="queryParams.frtCd" size="small" placeholder="请输入结算科目编码" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="结算科目名称:">
        <el-input v-model="queryParams.frtNm" size="small" placeholder="请输入结算科目名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="发票日期:">
        <el-date-picker v-model="queryParams.invoiceDt" type="date" value-format="yyyy-MM-dd" size="small" placeholder="选择发票日期" clearable />
      </el-form-item>
      <el-form-item label="财务对账ID:">
        <el-input v-model="queryParams.invSettleId" size="small" placeholder="请输入财务对账ID" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="财务结算ID:">
        <el-input v-model="queryParams.settlementId" size="small" placeholder="请输入财务结算ID" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="备用单据号:">
        <el-input v-model="queryParams.billNo" size="small" placeholder="请输入备用单据号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="是否来自费率表:">
        <el-input v-model="queryParams.autoYn" size="small" placeholder="请输入是否来自费率表" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="账期:">
        <el-input v-model="queryParams.pcTerm" size="small" placeholder="请输入账期" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="物料名称:">
        <el-input v-model="queryParams.cargoObjectName" size="small" placeholder="请输入物料名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="金额:">
        <el-input v-model="queryParams.amount" size="small" placeholder="请输入金额" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="已付款金额:">
        <el-input v-model="queryParams.paiedFee" size="small" placeholder="请输入已付款金额" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="对应应收:">
        <el-input v-model="queryParams.amtAr" size="small" placeholder="请输入对应应收" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="未付款金额:">
        <el-input v-model="queryParams.remainedAmount" size="small" placeholder="请输入未付款金额" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="批号:">
        <el-input v-model="queryParams.batchWorkorderNo" size="small" placeholder="请输入批号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="发货单位:">
        <el-input v-model="queryParams.shippedQtyUnit" size="small" placeholder="请输入发货单位" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="发货人姓名:">
        <el-input v-model="queryParams.shipperName" size="small" placeholder="请输入发货人姓名" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="对账对象:">
        <el-input v-model="queryParams.settlementApplicant" size="small" placeholder="请输入对账对象" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="源头订单明细编码:">
        <el-input v-model="queryParams.sourceItemId" size="small" placeholder="请输入源头订单明细编码" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="结算基于:">
        <el-input v-model="queryParams.settleBasedOn" size="small" placeholder="请输入结算基于" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="结算基于单位:">
        <el-input v-model="queryParams.settleBasedOnUnit" size="small" placeholder="请输入结算基于单位" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <!-- 工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button v-hasPermission="['accounting:accArSkuMonthlySettlement:insert']" type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-hasPermission="['accounting:accArSkuMonthlySettlement:update']" type="success" icon="el-icon-edit" size="mini" :disabled="isSingle" @click="handleEdit">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button v-hasPermission="['accounting:accArSkuMonthlySettlement:delete']" type="danger" icon="el-icon-delete" size="mini" :disabled="isMultiple" @click="handleRemove">删除</el-button>
      </el-col>
      <right-toolbar :show-search.sync="searchVisible" @queryTable="handleQuery" />
    </el-row>

    <!-- 数据列表 -->
    <el-table v-loading="loading" :data="page.records" highlight-current-row @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="ID" align="center" prop="id" />
      <el-table-column label="发票号" align="center" prop="invoiceNo" />
      <el-table-column label="支付流水号" align="center" prop="slipNo" />
      <el-table-column label="" align="center" prop="storeName" />
      <el-table-column label="店铺ID" align="center" prop="storeId" />
      <el-table-column label="" align="center" prop="mallName" />
      <el-table-column label="商城ID" align="center" prop="mallId" />
      <el-table-column label="结算状态" align="center" prop="status" />
      <el-table-column label="财务审核状态" align="center" prop="fixStatus" />
      <el-table-column label="所属域" align="center" prop="site" />
      <el-table-column label="付款收款人(这里指供应商)" align="center" prop="payCust" />
      <el-table-column label="付款人" align="center" prop="billToCust" />
      <el-table-column label="是否合作伙伴" align="center" prop="ptnrYn" />
      <el-table-column label="凭证日期" align="center" prop="slipDt" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.slipDt, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="结算货币金额" align="center" prop="amtCur" />
      <el-table-column label="汇总年月" align="center" prop="jobMonth" />
      <el-table-column label="汇率" align="center" prop="exrate" />
      <el-table-column label="结算货币" align="center" prop="curr" />
      <el-table-column label="SKU单价" align="center" prop="rate" />
      <el-table-column label="汇总结算数量" align="center" prop="wtCnt" />
      <el-table-column label="结算科目编码" align="center" prop="frtCd" />
      <el-table-column label="结算科目名称" align="center" prop="frtNm" />
      <el-table-column label="发票日期" align="center" prop="invoiceDt" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.invoiceDt, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="财务对账ID" align="center" prop="invSettleId" />
      <el-table-column label="财务结算ID" align="center" prop="settlementId" />
      <el-table-column label="备用单据号" align="center" prop="billNo" />
      <el-table-column label="输入类型" align="center" prop="inputType" />
      <el-table-column label="是否来自费率表" align="center" prop="autoYn" />
      <el-table-column label="账期" align="center" prop="pcTerm" />
      <el-table-column label="SKU编码" align="center" prop="cargoObjectNo" />
      <el-table-column label="物料名称" align="center" prop="cargoObjectName" />
      <el-table-column label="金额" align="center" prop="amount" />
      <el-table-column label="已付款金额" align="center" prop="paiedFee" />
      <el-table-column label="收货人名称" align="center" prop="consigneeName" />
      <el-table-column label="对应应收" align="center" prop="amtAr" />
      <el-table-column label="未付款金额" align="center" prop="remainedAmount" />
      <el-table-column label="批号" align="center" prop="batchWorkorderNo" />
      <el-table-column label="发货单位" align="center" prop="shippedQtyUnit" />
      <el-table-column label="发货人姓名" align="center" prop="shipperName" />
      <el-table-column label="付款类型" align="center" prop="paymentType" />
      <el-table-column label="对账对象" align="center" prop="settlementApplicant" />
      <el-table-column label="源头订单明细编码" align="center" prop="sourceItemId" />
      <el-table-column label="结算基于" align="center" prop="settleBasedOn" />
      <el-table-column label="结算基于单位" align="center" prop="settleBasedOnUnit" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button v-hasPermission="['accounting:accArSkuMonthlySettlement:update']" size="mini" type="text" icon="el-icon-edit" @click="handleEdit(scope.row)">修改</el-button>
          <el-button v-hasPermission="['accounting:accArSkuMonthlySettlement:delete']" size="mini" type="text" icon="el-icon-delete" @click="handleRemove(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页 -->
    <pagination v-show="page.total>0" :total="page.total" :page.sync="page.current" :limit.sync="page.pageSize" @pagination="handleQuery" />

    <!-- 添加/修改对话框 -->
    <el-dialog :title="accArSkuMonthlySettlementFormDialog.title" :visible.sync="accArSkuMonthlySettlementFormDialog.visible" :close-on-click-modal="false" :before-close="resetAccArSkuMonthlySettlementFormDialog" width="500px" append-to-body>
      <el-form ref="accArSkuMonthlySettlementForm" :model="accArSkuMonthlySettlementFormData" :rules="accArSkuMonthlySettlementFormRules" label-width="80px">
        <el-form-item label="发票号" prop="invoiceNo">
          <el-input v-model="accArSkuMonthlySettlementFormData.invoiceNo" placeholder="请输入发票号" />
        </el-form-item>
        <el-form-item label="支付流水号" prop="slipNo">
          <el-input v-model="accArSkuMonthlySettlementFormData.slipNo" placeholder="请输入支付流水号" />
        </el-form-item>
        <el-form-item label="" prop="storeName">
          <el-input v-model="accArSkuMonthlySettlementFormData.storeName" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="" prop="mallName">
          <el-input v-model="accArSkuMonthlySettlementFormData.mallName" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="所属域" prop="site">
          <el-input v-model="accArSkuMonthlySettlementFormData.site" placeholder="请输入所属域" />
        </el-form-item>
        <el-form-item label="付款收款人(这里指供应商)" prop="payCust">
          <el-input v-model="accArSkuMonthlySettlementFormData.payCust" placeholder="请输入付款收款人(这里指供应商)" />
        </el-form-item>
        <el-form-item label="付款人" prop="billToCust">
          <el-input v-model="accArSkuMonthlySettlementFormData.billToCust" placeholder="请输入付款人" />
        </el-form-item>
        <el-form-item label="是否合作伙伴" prop="ptnrYn">
          <el-input v-model="accArSkuMonthlySettlementFormData.ptnrYn" placeholder="请输入是否合作伙伴" />
        </el-form-item>
        <el-form-item label="凭证日期" prop="slipDt">
          <el-date-picker v-model="accArSkuMonthlySettlementFormData.slipDt" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择凭证日期" clearable />
        </el-form-item>
        <el-form-item label="结算货币金额" prop="amtCur">
          <el-input v-model="accArSkuMonthlySettlementFormData.amtCur" placeholder="请输入结算货币金额" />
        </el-form-item>
        <el-form-item label="汇总年月" prop="jobMonth">
          <el-input v-model="accArSkuMonthlySettlementFormData.jobMonth" placeholder="请输入汇总年月" />
        </el-form-item>
        <el-form-item label="汇率" prop="exrate">
          <el-input v-model="accArSkuMonthlySettlementFormData.exrate" placeholder="请输入汇率" />
        </el-form-item>
        <el-form-item label="结算货币" prop="curr">
          <el-input v-model="accArSkuMonthlySettlementFormData.curr" placeholder="请输入结算货币" />
        </el-form-item>
        <el-form-item label="SKU单价" prop="rate">
          <el-input v-model="accArSkuMonthlySettlementFormData.rate" placeholder="请输入SKU单价" />
        </el-form-item>
        <el-form-item label="汇总结算数量" prop="wtCnt">
          <el-input v-model="accArSkuMonthlySettlementFormData.wtCnt" placeholder="请输入汇总结算数量" />
        </el-form-item>
        <el-form-item label="结算科目编码" prop="frtCd">
          <el-input v-model="accArSkuMonthlySettlementFormData.frtCd" placeholder="请输入结算科目编码" />
        </el-form-item>
        <el-form-item label="结算科目名称" prop="frtNm">
          <el-input v-model="accArSkuMonthlySettlementFormData.frtNm" placeholder="请输入结算科目名称" />
        </el-form-item>
        <el-form-item label="发票日期" prop="invoiceDt">
          <el-date-picker v-model="accArSkuMonthlySettlementFormData.invoiceDt" type="date" value-format="yyyy-MM-dd" size="small" style="width: 100%" placeholder="选择发票日期" clearable />
        </el-form-item>
        <el-form-item label="财务对账ID" prop="invSettleId">
          <el-input v-model="accArSkuMonthlySettlementFormData.invSettleId" placeholder="请输入财务对账ID" />
        </el-form-item>
        <el-form-item label="财务结算ID" prop="settlementId">
          <el-input v-model="accArSkuMonthlySettlementFormData.settlementId" placeholder="请输入财务结算ID" />
        </el-form-item>
        <el-form-item label="备用单据号" prop="billNo">
          <el-input v-model="accArSkuMonthlySettlementFormData.billNo" placeholder="请输入备用单据号" />
        </el-form-item>
        <el-form-item label="是否来自费率表" prop="autoYn">
          <el-input v-model="accArSkuMonthlySettlementFormData.autoYn" placeholder="请输入是否来自费率表" />
        </el-form-item>
        <el-form-item label="账期" prop="pcTerm">
          <el-input v-model="accArSkuMonthlySettlementFormData.pcTerm" placeholder="请输入账期" />
        </el-form-item>
        <el-form-item label="物料名称" prop="cargoObjectName">
          <el-input v-model="accArSkuMonthlySettlementFormData.cargoObjectName" placeholder="请输入物料名称" />
        </el-form-item>
        <el-form-item label="金额" prop="amount">
          <el-input v-model="accArSkuMonthlySettlementFormData.amount" placeholder="请输入金额" />
        </el-form-item>
        <el-form-item label="已付款金额" prop="paiedFee">
          <el-input v-model="accArSkuMonthlySettlementFormData.paiedFee" placeholder="请输入已付款金额" />
        </el-form-item>
        <el-form-item label="对应应收" prop="amtAr">
          <el-input v-model="accArSkuMonthlySettlementFormData.amtAr" placeholder="请输入对应应收" />
        </el-form-item>
        <el-form-item label="未付款金额" prop="remainedAmount">
          <el-input v-model="accArSkuMonthlySettlementFormData.remainedAmount" placeholder="请输入未付款金额" />
        </el-form-item>
        <el-form-item label="批号" prop="batchWorkorderNo">
          <el-input v-model="accArSkuMonthlySettlementFormData.batchWorkorderNo" placeholder="请输入批号" />
        </el-form-item>
        <el-form-item label="发货单位" prop="shippedQtyUnit">
          <el-input v-model="accArSkuMonthlySettlementFormData.shippedQtyUnit" placeholder="请输入发货单位" />
        </el-form-item>
        <el-form-item label="发货人姓名" prop="shipperName">
          <el-input v-model="accArSkuMonthlySettlementFormData.shipperName" placeholder="请输入发货人姓名" />
        </el-form-item>
        <el-form-item label="对账对象" prop="settlementApplicant">
          <el-input v-model="accArSkuMonthlySettlementFormData.settlementApplicant" placeholder="请输入对账对象" />
        </el-form-item>
        <el-form-item label="源头订单明细编码" prop="sourceItemId">
          <el-input v-model="accArSkuMonthlySettlementFormData.sourceItemId" placeholder="请输入源头订单明细编码" />
        </el-form-item>
        <el-form-item label="结算基于" prop="settleBasedOn">
          <el-input v-model="accArSkuMonthlySettlementFormData.settleBasedOn" placeholder="请输入结算基于" />
        </el-form-item>
        <el-form-item label="结算基于单位" prop="settleBasedOnUnit">
          <el-input v-model="accArSkuMonthlySettlementFormData.settleBasedOnUnit" placeholder="请输入结算基于单位" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="confirmAccArSkuMonthlySettlementFormDialog">确 定</el-button>
        <el-button @click="resetAccArSkuMonthlySettlementFormDialog">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import AccArSkuMonthlySettlementApi from '@/api/accounting/AccArSkuMonthlySettlementApi'

const defaultAccArSkuMonthlySettlementFormData = {
  invoiceNo: null,
  slipNo: null,
  storeName: null,
  storeId: null,
  mallName: null,
  mallId: null,
  status: '0',
  fixStatus: '0',
  site: null,
  payCust: null,
  billToCust: null,
  ptnrYn: null,
  slipDt: null,
  amtCur: null,
  jobMonth: null,
  exrate: null,
  curr: null,
  rate: null,
  wtCnt: null,
  frtCd: null,
  frtNm: null,
  invoiceDt: null,
  invSettleId: null,
  settlementId: null,
  billNo: null,
  inputType: null,
  autoYn: null,
  pcTerm: null,
  cargoObjectNo: null,
  cargoObjectName: null,
  amount: null,
  paiedFee: null,
  consigneeName: null,
  amtAr: null,
  remainedAmount: null,
  batchWorkorderNo: null,
  shippedQtyUnit: null,
  shipperName: null,
  paymentType: null,
  settlementApplicant: null,
  sourceItemId: null,
  settleBasedOn: null,
  settleBasedOnUnit: null,
}
export default {
  name: 'AccArSkuMonthlySettlementList',
  data() {
    return {
      options: {
        sysYnTypeOptions: this.$constant.sysYnTypeOptions
      },
      queryParams: {
        invoiceNo: null,
        slipNo: null,
        storeName: null,
        storeId: null,
        mallName: null,
        mallId: null,
        status: null,
        fixStatus: null,
        site: null,
        payCust: null,
        billToCust: null,
        ptnrYn: null,
        slipDt: null,
        amtCur: null,
        jobMonth: null,
        exrate: null,
        curr: null,
        rate: null,
        wtCnt: null,
        frtCd: null,
        frtNm: null,
        invoiceDt: null,
        invSettleId: null,
        settlementId: null,
        billNo: null,
        inputType: null,
        autoYn: null,
        pcTerm: null,
        cargoObjectNo: null,
        cargoObjectName: null,
        amount: null,
        paiedFee: null,
        consigneeName: null,
        amtAr: null,
        remainedAmount: null,
        batchWorkorderNo: null,
        shippedQtyUnit: null,
        shipperName: null,
        paymentType: null,
        settlementApplicant: null,
        sourceItemId: null,
        settleBasedOn: null,
        settleBasedOnUnit: null,
        isValid: this.$constant.Y
      },
      page: {
        current: 1,
        pageSize: 10,
        total: 0,
        records: []
      },
      accArSkuMonthlySettlementFormDialog: {
        title: '',
        visible: false
      },
      accArSkuMonthlySettlementFormData: Object.assign({}, defaultAccArSkuMonthlySettlementFormData),
      accArSkuMonthlySettlementFormRules: {
      },
      loading: true,
      searchVisible: true,
      multipleSelection: [],
      isSingle: true,
      isMultiple: true
    }
  },
  created() {
    this.handleQuery()
    this.loadOptions()
  },
  methods: {
    loadOptions() {
    },
    handleAdd() {
      this.openAccArSkuMonthlySettlementFormDialog()
    },
    handleRemove(row) {
      const ids = row.id || this.multipleSelection.map(item => item.id)
      this.$confirm('是否确认删除数据?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        return AccArSkuMonthlySettlementApi.remove(ids)
      }).then(() => {
        this.handleQuery()
        this.$message.success('删除成功')
      })
    },
    handleEdit(row) {
      const id = row.id || this.multipleSelection.map(item => item.id)[0]
      this.openAccArSkuMonthlySettlementFormDialog(id)
    },
    handleQuery() {
      this.loading = true
      AccArSkuMonthlySettlementApi.page(this.queryParams, this.page).then(response => {
        this.page.records = response.data.records
        this.page.total = response.data.total
        this.loading = false
      }, () => {
        this.loading = false
      })
    },
    handleExport() {
      this.$confirm('是否确认导出数据?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function() {
        return AccArSkuMonthlySettlementApi.exportData(this.queryParams)
      }).then(response => {
        this.$common.download(response.data)
      })
    },
    openAccArSkuMonthlySettlementFormDialog(id) {
      this.accArSkuMonthlySettlementFormDialog.visible = true
      if (id) {
        this.accArSkuMonthlySettlementFormDialog.title = '财务月度sku汇总-修改'
        AccArSkuMonthlySettlementApi.get(id).then(response => {
          this.accArSkuMonthlySettlementFormData = {
            ...this.accArSkuMonthlySettlementFormData,
            ...response.data
          }
        })
      } else {
        this.accArSkuMonthlySettlementFormDialog.title = '财务月度sku汇总-添加'
      }
    },
    confirmAccArSkuMonthlySettlementFormDialog() {
      this.$refs['accArSkuMonthlySettlementForm'].validate(valid => {
        if (valid) {
          if (this.accArSkuMonthlySettlementFormData.id) {
            AccArSkuMonthlySettlementApi.edit(this.accArSkuMonthlySettlementFormData).then(response => {
              this.$message.success('修改成功')
              this.resetAccArSkuMonthlySettlementFormDialog()
              this.handleQuery()
            })
          } else {
            AccArSkuMonthlySettlementApi.add(this.accArSkuMonthlySettlementFormData).then(response => {
              this.$message.success('添加成功')
              this.resetAccArSkuMonthlySettlementFormDialog()
              this.handleQuery()
            })
          }
        }
      })
    },
    resetAccArSkuMonthlySettlementFormDialog() {
      this.accArSkuMonthlySettlementFormDialog = {
        title: '',
        visible: false
      }
      this.accArSkuMonthlySettlementFormData = Object.assign({}, defaultAccArSkuMonthlySettlementFormData)
      this.resetForm('accArSkuMonthlySettlementForm')
    },
    handleSelectionChange(selection) {
      this.multipleSelection = selection
      this.isSingle = selection.length !== 1
      this.isMultiple = !selection.length
    },
    resetQuery() {
      this.page.current = 1
      this.resetForm('queryForm')
      this.handleQuery()
    }
  }
}
</script>
